import 'package:json_annotation/json_annotation.dart';

import 'product_detail.dart';

part 'business_condition.g.dart';

@JsonSerializable()
class BusinessCondition {
  final StoreBusinessInfo curStoreBusinessInfo;
  final List<PurchaseCondition> purchaseConditions;

  BusinessCondition(this.curStoreBusinessInfo, this.purchaseConditions);

  factory BusinessCondition.fromJson(Map<String, dynamic> json) =>
      _$BusinessConditionFromJson(json);

  Map<String, dynamic> toJson() => _$BusinessConditionToJson(this);
}

@JsonSerializable()
class PurchaseCondition {
  final String conditionName;
  final String conditionCode;
  final StoreBusinessInfo storeBusinessInfo;
  final double needConsumeAmount;
  final List<ProductOption> productOptions;
  final String accountTypeTag;

  PurchaseCondition(
    this.conditionName,
    this.conditionCode,
    this.storeBusinessInfo,
    this.needConsumeAmount,
    this.productOptions,
    this.accountTypeTag,
  );

  factory PurchaseCondition.fromJson(Map<String, dynamic> json) =>
      _$PurchaseConditionFromJson(json);

  Map<String, dynamic> toJson() => _$PurchaseConditionToJson(this);
}

@JsonSerializable()
class StoreBusinessInfo {
  final int storeId;
  final String storeName;
  final String businessType;
  final String businessLevel;

  StoreBusinessInfo(this.storeId, this.storeName, this.businessType, this.businessLevel);

  factory StoreBusinessInfo.fromJson(Map<String, dynamic> json) =>
      _$StoreBusinessInfoFromJson(json);

  Map<String, dynamic> toJson() => _$StoreBusinessInfoToJson(this);
}

@JsonSerializable()
class ProductOption {
  final int id;
  final String productImageUrl;
  final String productModelName;
  final double coinAmount;
  final double pointCoins;
  final int minPurchaseAmount;
  final int referStoreId;
  final bool selected;
  final bool canModified;
  final List<Price> priceVos;

  ProductOption(
    this.id,
    this.productImageUrl,
    this.productModelName,
    this.coinAmount,
    this.pointCoins,
    this.minPurchaseAmount,
    this.referStoreId,
    this.selected,
    this.canModified,
    this.priceVos,
  );

  factory ProductOption.fromJson(Map<String, dynamic> json) => _$ProductOptionFromJson(json);

  Map<String, dynamic> toJson() => _$ProductOptionToJson(this);
}
